#include <iostream>
#include <algorithm>
using namespace std;
#define int long long 
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return (a * b) / gcd(a, b);
}
signed main() {
    int x, y;
    cin >> x >> y;
    int count = 0;
    for(int i = x; i <= y; i++) {
        if(i % x == 0 && y % i == 0) {
           for(int j = i; j <= y; j++) {
            if(gcd(i, j) == x) {
                if(lcm(i, j) == y) {
                    // cout << i << j << endl;
                    count++;
                }
            }
        } 
        }
        
    }
    if(x == y) {
        cout << count * 2 - 1 << endl;
        return 0;
    }
    cout << count * 2 << endl;
    return 0;
}